package com.leather.question.controller;

import com.leather.common.result.Result;
import com.leather.question.service.AnswerService;
import com.leather.question.vo.AnswerAddVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class AnswerController {

    @Autowired
    private AnswerService answerService;


    @PostMapping("addanswer")
    public Result addAnswer(AnswerAddVo answerAddVo) {
        return answerService.addAnswer(answerAddVo);
    }

    @GetMapping("getanswer")
    public Result getAnswer(int questionId, int pageId) {
        return answerService.getByquestionId(questionId, pageId * 10);
    }

    @PostMapping("deleteanswer")
    public Result deleteQuestion(int answerId, int userId) {
        return answerService.deleteAnswer(answerId, userId);
    }

    @GetMapping("getuseranswer")
    public Result getUserAnswer(int userId, int pageId) {
        return answerService.getUserAnswer(userId, pageId * 10);
    }

}
